package com.zzl.bonds.ticket.dto.finance;

import com.fasterxml.jackson.annotation.JsonFormat;
import com.fasterxml.jackson.annotation.JsonIgnore;
import com.fasterxml.jackson.databind.annotation.JsonSerialize;
import com.zzl.apidoc.annotation.ApidocModel;
import com.zzl.apidoc.annotation.ApidocModelProperty;
import com.zzl.apidoc.constants.RequiredType;
import com.zzl.bonds.ticket.constant.SourceTypeEnum;
import com.zzl.bonds.ticket.constant.status.TicketStatusEnum;
import com.zzl.bonds.ticket.constant.type.BusinessModeEnum;
import com.zzl.bonds.ticket.constant.type.FinanceBusinessTypeEnum;
import com.zzl.bonds.ticket.constant.type.SealTypeEnum;
import com.zzl.bonds.ticket.entity.TicketDataEntity;
import com.zzl.general.common.utils.DoubleSerialize;
import com.zzl.general.common.utils.DoubleToPercentSerialize;
import lombok.Data;

import java.io.Serializable;
import java.util.Date;
import java.util.List;

/**
 * 融资申请单复核详情
 *
 * @author gull
 * @date 2022-02-24 13:53:42
 */
@Data
@ApidocModel
public class TicketFinanceReviewDto implements Serializable {
    private static final long serialVersionUID = 1L;

    private String id;
    /**
     * 和产品确认：凭证归属，指的是票当前的持有银行
     */
    @ApidocModelProperty(description = "凭证归属")
    private String ticketAscription;

    public String getTicketAscription() {
        return ticketInstinctyName;
    }

    @ApidocModelProperty(description = "业务编号")
    private String financeBillNo;
    @ApidocModelProperty(description = "融资企业 id")
    private String enterpriseId;
    @ApidocModelProperty(description = "融资企业")
    private String financeEnterpriseName;
    @ApidocModelProperty(description = "金融机构id")
    private Integer instinctyId;
    @ApidocModelProperty(description = "金融机构")
    private String instinctyName;
    @JsonFormat(pattern = "yyyy-MM-dd")
    @ApidocModelProperty(description = "融资申请日期", validate = "yyyy-MM-dd")
    private Date createTime;
    @JsonSerialize(using = DoubleSerialize.class)
    @ApidocModelProperty(description = "融资本金")
    private Double sellAmount;
    @JsonSerialize(using = DoubleSerialize.class)
    @ApidocModelProperty(description = "转让金额")
    private Double transferAmount;
    @ApidocModelProperty(description = "入账银行账号")
    private String financeDepositBank;
    @ApidocModelProperty(description = "开户行")
    private String depositBank;

    @ApidocModelProperty(description = "凭证编号")
    private String ticketNo;
    @JsonSerialize(using = DoubleToPercentSerialize.class)
    @ApidocModelProperty(description = "融资利率")
    private Double annualizedInterestRate;
    @ApidocModelProperty(description = "预计融资利息")
    @JsonSerialize(using = DoubleSerialize.class)
    private Double estimatedFinancingInterest;
    @JsonSerialize(using = DoubleToPercentSerialize.class)
    @ApidocModelProperty(description = "平台服务费率")
    private Double platServiceRate;
    @ApidocModelProperty(description = "平台服务费率是否年化，0 否，1 是")
    private Integer isAnnualizedPlatServiceRate;
    @ApidocModelProperty(description = "宽限期是否计息，0 否，1 是")
    private Integer isGraceCost;
    @ApidocModelProperty(description = "宽限天数")
    private Integer graceDays;
    @ApidocModelProperty(description = "业务方式 1 无追索权")
    private String businessModeName;
    @ApidocModelProperty(description = "用章类型 1 公章")
    private String sealTypeName;
    @ApidocModelProperty(description = "业务类型 1 公开型")
    private String businessTypeName;

    public String getSealTypeName() {
        return SealTypeEnum.getValue(sealType);
    }

    public String getBusinessModeName() {
        return BusinessModeEnum.getValue(businessMode);
    }

    public String getBusinessTypeName() {
        return FinanceBusinessTypeEnum.getValue(businessType);
    }

    @JsonIgnore
    private Integer businessMode;
    @JsonIgnore
    private Integer sealType;
    @JsonIgnore
    private Integer businessType;
    @ApidocModelProperty(description = "预计服务费用（平台收取）")
    @JsonSerialize(using = DoubleSerialize.class)
    private Double serviceChage;
    @ApidocModelProperty(description = "预计融资天数")
    private String financingDayStr;
    @JsonIgnore
    private Integer financeDays;

    public String getFinancingDayStr() {
        return financeDays + "";
    }

    @ApidocModelProperty(description = "融资利率是否年化,0：否，1:是")
    private Integer isAnnualizedInterestRate;
    @ApidocModelProperty(description = "数据来源")
    private String dataChannelName;
    @JsonIgnore
    private Integer dataChannel;

    public String getDataChannelName() {
        return SourceTypeEnum.getValue(dataChannel);
    }

    /////////////////////////////////母单信息
    @ApidocModelProperty(description = "母单-凭证编号")
    private String parentTicketNo;
    @JsonSerialize(using = DoubleSerialize.class)
    @ApidocModelProperty(description = "母单-凭证金额")
    private Double parentTicketAmount;
    @ApidocModelProperty(description = "母单-开单企业")
    private String parentCoreEnterpriseName;
    @JsonFormat(pattern = "yyyy-MM-dd")
    @ApidocModelProperty(description = "母单-到期日期", validate = "yyyy-MM-dd")
    private Date parentCashTime;

    @ApidocModelProperty(description = "母单-转让企业id", required = RequiredType.TRUE)
    private String transferEnterpriseId;
    @ApidocModelProperty(description = "母单-转让企业", required = RequiredType.TRUE)
    private String transferEnterpriseName;
    @ApidocModelProperty(description = "母单-金融机构id")
    private String ticketInstinctyId;
    @ApidocModelProperty(description = "母单-金融机构")
    private String ticketInstinctyName;
    @ApidocModelProperty(description = "基础交易合同编号")
    private String contractNo;
    @JsonFormat(pattern = "yyyy-MM-dd")
    @ApidocModelProperty(description = "应收账款到期日期", validate = "yyyy-MM-dd")
    private Date receivableCashTime;

    public Date getReceivableCashTime() {
        return cashTime;
    }

    @JsonSerialize(using = DoubleSerialize.class)
    @ApidocModelProperty(description = "应收账款金额")
    private Double receivableAmount;

    @ApidocModelProperty(description = "开单企业id")
    private String coreEnterpriseId;
    @ApidocModelProperty(description = "开单企业名称")
    private String coreEnterpriseName;
    @JsonFormat(pattern = "yyyy-MM-dd")
    @ApidocModelProperty(description = "到期日期", validate = "yyyy-MM-dd")
    private Date cashTime;
    @ApidocModelProperty(description = "票据状态 1：融资待复核 2、融资已复核 3、平台待复核 4、平台已复核 5、待放款")
    private String ticketStatusName;
    @JsonIgnore
    private Integer ticketStatus;
    @ApidocModelProperty(description = "凭证金额")
    private Double ticketAmount;


    @ApidocModelProperty(description = "凭证资料")
    private List<TicketDataEntity> proofList;
    @ApidocModelProperty(description = "发票信息")
    private List<TicketDataEntity> invoiceList;
    @ApidocModelProperty(description = "签署资料")
    private List<TicketContractDto> protocolList;

    public Date getParentCashTime() {
        return cashTime;
    }

    public String getParentCoreEnterpriseName() {
        return coreEnterpriseName;
    }

    public String getTicketStatusName() {
        return TicketStatusEnum.getStatusName(ticketStatus);
    }
}
